package cn.itcast.service.cargo.impl;

import cn.hutool.core.util.IdUtil;
import cn.itcast.dao.cargo.ShippingDao;
import cn.itcast.domain.cargo.Packing;
import cn.itcast.domain.cargo.Shipping;
import cn.itcast.domain.cargo.ShippingExample;
import cn.itcast.service.cargo.ShippingService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@Service
public class ShippingServiceImpl implements ShippingService {
    @Autowired
    private ShippingDao shippingDao;
    @Override
    public int deleteByPrimaryKey(String shippingOrderId) {
        return shippingDao.deleteByPrimaryKey(shippingOrderId);
    }

    @Override
    public int insert(Shipping record) {
        return 0;
    }

    @Override
    public int insertSelective(Shipping record) {
        return 0;
    }

    @Override
    public List<Shipping> selectByExample(ShippingExample example) {
        return null;
    }

    @Override
    public Shipping selectByPrimaryKey(String shippingOrderId) {
        return shippingDao.selectByPrimaryKey(shippingOrderId);
    }

    @Override
    public int updateByPrimaryKeySelective(Shipping record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Shipping record) {
        return 0;
    }


    @Override
    public PageInfo findByPage(int pageNum, int pageSize, ShippingExample shippingExample) {
        PageHelper.startPage(pageNum,pageSize);
        List<Shipping> list = shippingDao.selectByExample(shippingExample);
        return new PageInfo(list);
    }

    @Override
    public void save(Shipping shipping,String packingListId) {
        shipping.setShippingOrderId(packingListId);
        shipping.setState(0);
        shippingDao.insertSelective(shipping);
    }

    @Override
    public void update(Shipping shipping) {
        shippingDao.updateByPrimaryKeySelective(shipping);
    }
}
